package com.xzy.seckill.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {
    public static final String STOCK_QUEUE = "stockQueue";
    public static final String ORDER_QUEUE = "orderQueue";
    public static final String SEC_EXCHANGE = "secExchange";


    @Bean
    public Queue stockQueue(){
        return new Queue(STOCK_QUEUE);
    }
    @Bean
    public Queue orderQueue(){
        return new Queue(ORDER_QUEUE);
    }

    @Bean
    public TopicExchange secExchange(){
        return new TopicExchange(SEC_EXCHANGE);
    }

    @Bean
    public Binding stockQueueBind(){
        return BindingBuilder.bind(stockQueue()).to(secExchange()).with("secKill.stock");
    }
    @Bean
    public Binding orderQueueBind(){
        return BindingBuilder.bind(orderQueue()).to(secExchange()).with("secKill.order");
    }




}
